package com.example.qianjun.gobang01;

import android.content.Intent;
import android.content.SharedPreferences;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;

import com.example.qianjun.gobang01.bean.Constant;

public class PreMainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_pre_main);


        //Constant.chessStyleInit();
        for(int m=0;m<Constant.chessStyleFives.length;m++){
            Log.i("tom",Constant.chessStyleFives[m].getChessStyle());
        }

        SharedPreferences config = getSharedPreferences("gobangConfig",MODE_PRIVATE);
        //如果是第一次启动APP，那么进行参数的初始化操作
        if(config.getBoolean("firstStartAPP",true)){
            SharedPreferences.Editor editor = config.edit();

            editor.putBoolean("firstStartAPP",false);

            //默认棋盘大小为10*10
            editor.putInt("table_x", Constant.SMALL_CHECKBOARD_X);
            editor.putInt("table_y",Constant.SMALL_CHECKBOARD_Y);
            //默认对弈顺序为执黑先行
            editor.putInt("chessOrder",Constant.CHOSE_BLACK_FIRST);
            //默认机器人棋手等级为新手级
            editor.putInt("robotPlayerLevel",Constant.ROBOT_LEVEL_FIRST);
            //默认提示机器人等级为新手级
            editor.putInt("noticeRobotplayerLevel",Constant.ROBOT_LEVEL_FIRST);
            //默认落子提示边框为方形
            editor.putInt("pieceNoticeStyle",Constant.PIECE_NOTICE_STYLE_RECT);
            //倒计时初始化, 默认30s
            editor.putInt("countDownTime",Constant.COUNT_DOWN_NUMBER_30);

            //提交更改
            editor.commit();
        }

        new Thread(){
            @Override
            public void run() {

                try {
                    Thread.sleep(1500);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }

                Intent intent = new Intent(PreMainActivity.this,MainActivity.class);
                startActivity(intent);
                finish();
            }
        }.start();


    }
}
